//
//  UUIntentOrderDetailBidVC.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 02/03/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUIntentOrderDetailBidVC.h"

@interface UUIntentOrderDetailBidVC ()

@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *stateLabel;
@property (nonatomic, strong) UILabel *dateLabel;

@end

@implementation UUIntentOrderDetailBidVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    DKAssert(self.bidModel != nil);
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.stateLabel = [UILabel new];
    self.stateLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.stateLabel];
    [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(23);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(20);
    }];
    
    self.dateLabel = [UILabel new];
    self.dateLabel.font = [UIFont systemFontOfSize:12];
    self.dateLabel.textColor = COMMON_TEXT_LIGHT_COLOR;
    [self.view addSubview:self.dateLabel];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.bottom.mas_equalTo(-11);
        make.height.mas_equalTo(17);
    }];
    
    self.priceLabel = [UILabel new];
    [self.view addSubview:self.priceLabel];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel);
        make.top.equalTo(self.stateLabel);
        make.height.mas_equalTo(20);
    }];
    
    self.dateLabel.text = [self.bidModel.createTime formatDateByFormatString:@"yyyy.MM.dd HH:mm"];
    
    switch (self.bidModel.status) {
        case UUIntentOrderBidStatusBiding:
            self.stateLabel.text = @"等待回应";
            self.stateLabel.textColor = COMMON_TEXT_RED_COLOR;
            break;
        case UUIntentOrderBidStatusReject:
            self.stateLabel.text = @"已拒绝";
            self.stateLabel.textColor = COMMON_TEXT_LIGHT_COLOR;
            break;
        case UUIntentOrderBidStatusComplete:
            self.stateLabel.text = @"已成交";
            self.stateLabel.textColor = COMMON_TEXT_GREEN_COLOR;
            break;
        case UUIntentOrderBidStatusInvalid:
            self.stateLabel.text = @"已失效";
            self.stateLabel.textColor = COMMON_TEXT_LIGHT_COLOR;
            break;
        default:
            DKAssert(0);
            break;
    }
    
    NSMutableAttributedString *priceAttributedText = [[NSMutableAttributedString alloc] initWithString:@"报价 "
                                                                                            attributes:@{
                                                                                                         NSFontAttributeName : [UIFont systemFontOfSize:14],
                                                                                                         NSForegroundColorAttributeName : COMMON_TEXT_LIGHT_COLOR
                                                                                                         }];
    
    [priceAttributedText appendAttributedString:[[NSAttributedString alloc] initWithString:@"￥"
                                                                                attributes:@{
                                                                                             NSFontAttributeName : [UIFont systemFontOfSize:12],
                                                                                             NSForegroundColorAttributeName : COMMON_TEXT_RED_COLOR
                                                                                             }]];
    
    [priceAttributedText appendAttributedString:[[NSAttributedString alloc] initWithString:[self.bidModel.price toCurrencyWithoutCurrencySymbol]
                                                                                attributes:@{
                                                                                             NSFontAttributeName : [UIFont systemFontOfSize:19],
                                                                                             NSForegroundColorAttributeName : COMMON_TEXT_RED_COLOR
                                                                                             }]];
    
    self.priceLabel.attributedText = priceAttributedText;
    
    self.preferredContentSize = CGSizeMake(0, 95);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
